package com.atwisdom.star.common.vo;

public enum StatusCode {
    //http返回值
    //200：正常
    SUCCESS(200,"成功"),

    SUCCESS_UPDATE(200,"更新操作成功"),
    SUCCESS_ADD(200,"新增操作成功"),

    SUCCESS_DELETE(200,"删除操作成功"),
    SUCCESS_FILE(200,"文件操作成功"),

    //4xx：权限错误
    ACCOUNT_CAN_NOT_BE_EMPTY(410,"登录的用户账号不能为空!"),
    NOT_EXIST_USER(411,"用户不存在!"),
    ACCOUNT_UN_ACTIVE(412,"您的账户尚未激活，请联系管理员激活!"),
    PASSWORD_ERROR(413,"登录密码错误!"),
    NOT_EXIST_TENANT(414,"租户不存在"),

    PASSWORD_EMPTY_ERROR(415,"登录的用户账号密码不能为空!"),

    //5xx：其他错误
    RUN_ERROR(500,"程序内部错误，请联系管理员"),
    ERROR_UPLOAD_FILE(500,"文件上传失败！"),
    ERROR_DOWNLOAD_FILE(500,"文件下载失败！"),
    ID_MISS(501,"没有指定ID"),
    DUPLICATE_KEY(502,"对象已存在"),
    //文件处理失败,
    ERROR_MODEL_NOT_EXIST(503,"模型不存在，操作失败！"),

    ERROR_QUERY(505,"查询操作失败！"),
    ERROR_UPDATE(506,"更新操作失败！"),
    ERROR_INVALID_UPDATE(507,"不安全更新，操作失败！"),
    ERROR_ADD(508,"新增操作失败！"),
    ERROR_ADD_CLASS_VERSION(509,"模型名称和版本号不能为空，新增操作失败！"),

    ERROR_CREATE(510,"实例创建失败！"),
    ERROR_DELETE(511,"删除操作失败！"),
    ERROR_INVALID_DELETE(512,"不安全删除，操作失败！"),
    ERROR_REGISTER(513,"容器注册失败！"),
    ERROR_UNREGISTER(514,"容器注销失败！"),
    ERROR_MOVE_IN(515,"容器移入失败！"),
    ERROR_MOVE_OUT(516,"容器移出失败！"),
    ERROR_CALCULATE(517,"表达式计算失败！"),

    ERROR_PUBLISHED(518,"模型名称和版本号不能为空，发布操作失败！"),
    ERROR_PUBLISHED_ACTION(519,"数据异常，发布操作失败！"),
    ERROR_UNPUBLISHED(520,"模型名称和版本号不能为空，取消发布操作失败！"),
    ERROR_UNPUBLISHED_ACTION(521,"数据异常，取消发布操作失败！"),

    ERROR_MODEL_ADD_CLASS_EMPTY(522,"模型名称不能为空，新增操作失败！"),
    ERROR_MODEL_ADD_CLASS_EXIST(523,"模型已存在，新增操作失败！"),

    ERROR_UPDATE_ID_NULL(524,"要更新的数据主键标识ID为NULL,更新操作失败！"),
    ERROR_INSTANCE_ADD_CLASS_EMPTY(522,"模型名称为空，新增实例操作失败！"),
    ERROR_ADD_INSTANCE_EXIST(523,"模型实例存在，新增实例操作失败！"),
    ERROR_ADD_MODEL_NOT_EXIST(524,"模型不存在，新增实例操作失败！"),
    ERROR_INVALID_OPERATION(525,"无效操作！"),
    ERROR_REGISTER_HIER_IS_EMPTY(526,"模型实例注册容器传参为空，注册失败！"),
    ERROR_REGISTER_INSTANCE_NOT_EXIST(527,"未找找到模型实例，注册失败！"),
    ERROR_INIT_REGISTER_ONE_MORE_INSTANCE(528,"模型实例多佘一个，配置注册失败！"),
    ERROR_INIT_REGISTER_NOT_EXIST_OR_ONE_MORE_INSTANCE(529,"模型实例未找到或多佘一个，配置注册失败！"),
    ERROR_RUN_UNREGISTER_NOT_EXIST_REGISTER(530,"模型实例未注册项，取消注册失败！"),
    ERROR_SUBSCRIBE_INSTANCE_NOT_EXIST(531,"未找找到模型实例，订阅失败！"),
    ERROR_SUBSCRIBE_OTHERS_IS_EMPTY(533,"模型实例注册容器传参为空，注册失败！"),
    ERROR_SUBSCRIBE_BASIC_IS_EMPTY(534,"模型实例注册容器basic传参为空，注册失败！"),
    ERROR_UNSUBSCRIBE_INSTANCE_NOT_EXIST(535,"未找找到模型实例，取消订阅失败！"),
    ERROR_SCHEDULER_JOB_STILL_RUNNING(536,"定时任务不是停止状态，请先停止任务"),
    ERROR_DATA_ERROR(537,"数据有误"),
    ERROR_ERP_ERROR(538,"调用ERP错误"),
    ERROR_WORK_ORDER_NOT_FOUND_REVOKE(539,"未查到工单，撤销无效"),
    ERROR_WORK_ORDER_EXIST_SUB_DATA_REVOKE(540,"工单存在下由单据，撤销无效"),
    ERROR_PRODUCTION_PLAN_ORDER_NOT_FOUND(540,"生产计划订单不存在，解锁无效"),
    ERROR_WORK_ORDER_IS_CREATED(541,"生产计划订单已创建生产工单，解锁无效"),
    ERROR_PRODUCTION_PLAN_ORDER_NOT_LOCK(540,"生产计划订单没有锁定，无需解锁"),
    ERROR_PARAM_NULL(550,"参数空值错误！"),
    ERROR_BACKUP(10000,"备用");
    private StatusCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMessage(int code) {
        for(StatusCode res : StatusCode.values()) {
            if(res.getCode() == code) {
                return res.message;
            }
        }
        return null;
    }


    private int code;

    private String message;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
